package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.WalletFlow;
import com.ruoyi.bizsys.service.IWalletFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 钱包流水Controller
 *
 * @author african-loan
 * @date 2022-06-17
 */
@RestController
@RequestMapping("/wallet/wallet_flow")
public class WalletFlowController extends BaseController {
    @Autowired
    private IWalletFlowService walletFlowService;

/**
 * 查询钱包流水列表
 */
@PreAuthorize("@ss.hasPermi('wallet:wallet_flow:list')")
@GetMapping("/list")
        public TableDataInfo list(WalletFlow walletFlow) {
        startPage();
        List<WalletFlow> list = walletFlowService.selectWalletFlowList(walletFlow);
        return getDataTable(list);
    }
    
    /**
     * 导出钱包流水列表
     */
    @PreAuthorize("@ss.hasPermi('wallet:wallet_flow:export')")
    @Log(title = "钱包流水", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WalletFlow walletFlow) {
        List<WalletFlow> list = walletFlowService.selectWalletFlowList(walletFlow);
        ExcelUtil<WalletFlow> util = new ExcelUtil<WalletFlow>(WalletFlow.class);
        return util.exportExcel(list, "wallet_flow");
    }

    /**
     * 获取钱包流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('wallet:wallet_flow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(walletFlowService.selectWalletFlowById(id));
    }

    /**
     * 新增钱包流水
     */
    @PreAuthorize("@ss.hasPermi('wallet:wallet_flow:add')")
    @Log(title = "钱包流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WalletFlow walletFlow) {
        return toAjax(walletFlowService.insertWalletFlow(walletFlow));
    }

    /**
     * 修改钱包流水
     */
    @PreAuthorize("@ss.hasPermi('wallet:wallet_flow:edit')")
    @Log(title = "钱包流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WalletFlow walletFlow) {
        return toAjax(walletFlowService.updateWalletFlow(walletFlow));
    }

    /**
     * 删除钱包流水
     */
    @PreAuthorize("@ss.hasPermi('wallet:wallet_flow:remove')")
    @Log(title = "钱包流水", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(walletFlowService.deleteWalletFlowByIds(ids));
    }
}
